15:00
Slides: bit.ly/2024-rss-quarto
No need to install anything!
URL: https://quarto-workshop.jumpingrivers.training/welcome/.
Enter an email and the password grapefruit-kiwi.
https://quarto-workshop.jumpingrivers.training/welcome/
Password: grapefruit-kiwi
Background in Astrophysics.
Data Scientist @ Jumping Rivers:
Python support for various clients.
Teach courses in Python, SQL, ML.
Hobbies include hiking and travelling.
↗ jumpingrivers.com 𝕏 @jumping_uk
Quarto is a tool created by Posit (formerly RStudio).
Quarto has better multi-language support.
More user-friendly.
Better control of the output layouts.
There is an R package library(quarto).
New features will be added to Quarto.
File > New File > Quarto Document
Set title and author
Click Create
Save and click Render
YAML: Yet Another Markup Language
Or type into a Quarto document:
Use the Visual editor - click Insert –> Figure/Image
Or type into a Quarto document:
File > New File > Quarto Document.
Set title and author.
Click Create.
Save and click Render.
Add the text from task1.txt.
Add a link to the Duke Lemur Center https://lemur.duke.edu/.
Add the image of the Mongoose Lemur.
15:00
… and lemurs…
You can load in your data using R:
If we’re just loading in packages, perhaps we should collapse the code…
… do some data wrangling, and print the output as a table…
| sex | weight_g | age_at_wt_mo |
|---|---|---|
| M | 1086 | 125.82 |
| M | 1190 | 129.93 |
| F | 947 | 131.11 |
| F | 1174 | 135.42 |
| M | 899 | 100.64 |
| M | 917 | 101.06 |
…or include some exploratory plots!
```{r}
#| message: false
#| output-location: slide
#| fig-cap: "Age vs weight of lemurs"
#| fig-alt: "Scatter plot showing positive relationship between lemur age and weight split by sex"
#| out-width: 150%
ggplot(data = df,
mapping = aes(x = age_at_wt_mo,
y = weight_g,
colour = sex)) +
geom_point(alpha = 0.1) +
geom_smooth(method = "lm") +
labs(title = "Weight of lemurs",
x = "Age (months)",
y = "Weight (g)")
```We can also include code inline, rather than as a separate chunk.
The number of observations is `r num_obs`.
The number of observations is 82609.
Add a code block to load the data and libraries (see task-2.R).
Set the code chunk options to hide the code and messages.
Add a second code block to make a scatter plot.
Add a caption to the plot with the fig-cap code chunk option.
Add a final code chunk to find the average weight.
15:00
Let’s explore some more use cases!
Great way to demonstrate code:
Engaging format for teaching!
Flexible CSS styling that can be shared.
LaTeX backend for PDF documents.
Try quarto-journals for correctly formatted journal articles!
E.g. for the Journal of Statistical Software article:
More journal templates at awesome-quarto.
Access these parameters with params$species
Everything we’ve shown here can also be done in Python!
Fence code cells with {python} instead of {r}.
VS Code and Jupyter Lab are both supported by Quarto.
Inline code and parameters have different syntax in Python.
See Python Quarto docs for details.
It’s easy to share your documents!
Quarto resources